﻿@using FujiyBlog.Core.DomainObjects
@using FujiyBlog.Core.Extensions

@model FujiyBlog.Web.ViewModels.WidgetIndex
           
<div class="widgetzone" id="widgetzone_@(Model.ZoneName)">
    @foreach (WidgetSetting widgetSetting in Model.WidgetSettings)
    {
        Html.RenderPartial(widgetSetting.Name, widgetSetting);
    }
</div>
@if (User.IsInRole(Role.ManageWidgets))
{
    <script type="text/javascript">
        var shouldStartDragAndDrop = true;
    </script>
    
    <div id="addedwidgets"></div>
    using (Ajax.BeginForm(MVC.Widget.Add(Model.ZoneName, null), new AjaxOptions { OnSuccess = "fujiyBlog.widget.showAddedWidget('widgetzone_" + Model.ZoneName + "', arguments[0]);" }, new { id = "addwidgetform" + Model.ZoneName }))
    { 
    @Html.DropDownList("widgetName", Model.AvailableWidgets.Select(x => new SelectListItem { Text = x }), Resources.Labels.Select)
    <a href="javascript:void(0);" onclick="javascript:$('#addwidgetform@(Model.ZoneName)').trigger('submit');">
        @Resources.Labels.Add</a>
    }
}